Cleanups saved for a rainy day? Even without being called out via valgrind, these
authorrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 5 Jan 2014 22:44:22 +0000 (22:44 +0000)
committerrobertlipe@gmail.com <robertlipe@gmail.com@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Sun, 5 Jan 2014 22:44:22 +0000 (22:44 +0000)
are "obviously" leaks and a cleanup upportunity.
 egrep -- '->(rte_name|rte_desc|rte_url|icon|icon_descr|rte_name|rte_desc|notes|shortname|description) = xstrdup' *.cca
We've eliminated 58% of the calls to xstrdup that we had in 1.4.4..

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4712 f51c46e8-681c-474f-0cfe-069cfd0219fb

19 files changed:
gpsbabel/an1.cc
gpsbabel/brauniger_iq.cc
gpsbabel/cst.cc
gpsbabel/delbin.cc
gpsbabel/dg-100.cc
gpsbabel/garmin.cc
gpsbabel/glogbook.cc
gpsbabel/ignrando.cc
gpsbabel/lmx.cc
gpsbabel/mapsource.cc
gpsbabel/mmo.cc
gpsbabel/naviguide.cc
gpsbabel/navilink.cc
gpsbabel/overlay.cc
gpsbabel/ozi.cc
gpsbabel/radius.cc
gpsbabel/shape.cc
gpsbabel/stmwpp.cc
gpsbabel/transform.cc

index d8d5cd13659a1bff5e7cceda9b13a3d51f0ed380..5943e31e815c6a8ce650bb267a4c8f6bfbde615b 100644 (file)
@@ -729,7 +729,7 @@ static void Read_AN1_Waypoints(gbfile* f)
 #endif
 
     if (rec->image_name) {
-      wpt_tmp->icon_descr = xstrdup(rec->image_name);
+      wpt_tmp->icon_descr = rec->image_name;
     } else if (FindIconByGuid(&rec->guid, &icon)) {
       wpt_tmp->icon_descr = icon;
     }
index c0e725d9a559694971b7716f8eb6adf95f8d99ea..a32f44a52a5f9a27611d1d64a61ef224508f6549 100644 (file)
@@ -191,8 +191,8 @@ static int process_data(const unsigned char* data)
     }
     if (remaining) {
       track = route_head_alloc();
-      track->rte_name = xstrdup(PRESTRKNAME);
-      track->rte_desc = xstrdup("Brauniger-IQ Barograph");
+      track->rte_name = PRESTRKNAME;
+      track->rte_desc = "Brauniger-IQ Barograph";
       track_add_head(track);
     } else {
       warning(MYNAME ": No barograph recorded for this flight\n");
index f7d3f95e6231c8bd015491d8abe6c6df3512cde0..894eaf44fa11a0c6afdfc08d9f217b8550247077 100644 (file)
@@ -236,11 +236,7 @@ cst_data_read(void)
             line++;
             cin = lrtrim(buff);
             if (*cin != '\0') {
-#if NEW_STRINGS
               wpt->notes = QString::fromLatin1(cin);
-#else
-              wpt->notes = xstrdup(cin);
-#endif
             }
           } else if (strcmp(cin + 2, "end") == 0) {
             data = 1;
@@ -286,11 +282,7 @@ cst_data_read(void)
           track = route_head_alloc();
           track_add_head(track);
         } else if (strncmp(name, "NAME:", 5) == 0) {
-#if NEW_STRINGS
           wpt->shortname = QString::fromLatin1(((char*)&name) + 5);
-#else
-          wpt->shortname = xstrdup(((char*)&name) + 5);
-#endif
         }
 
         pow = strrchr(cin, '^');
index f90f5744f354be192b9b769e06f6404458283756..08c47d1e546b8379920d96dae21c31f36a08930d 100644 (file)
@@ -1011,7 +1011,7 @@ decode_waypoint(const void* data)
 //    wp->icon_descr = wp->icon_descr;
 //  }
   if (p->name_size && p->name[0]) {
-    wp->description = xstrdup(p->name);
+    wp->description = p->name;
   }
   s = p->name + p->name_size;
   if (le_readu16(s) &&  s[2]) {
@@ -1401,13 +1401,8 @@ write_waypoint(const waypoint* wp)
   char* pp;
 
   if (waypt_empty_gc_data(wp)) {
-#if NEW_STRINGS
     notes = xstrdup(wp->notes);
     if (notes == NULL && wp->description.isEmpty() && wp->shortname != wp->description) {
-#else
-    notes = wp->notes;
-    if (notes == NULL && wp->description && strcmp(wp->shortname, wp->description)) {
-#endif
       notes = xstrdup(wp->description);
     }
     if (notes) {
@@ -1617,7 +1612,7 @@ read_track(route_head* track)
   // process track messages
   p = (const msg_track_header_t*) msg_array[0].data;
   if (le_readu16(p->comment_size)) {
-    track->rte_desc = xstrdup(p->comment);
+    track->rte_desc = p->comment;
   }
   track->line_color.bbggrr = track_color(p->color[0]);
   n_point = le_readu32(p->total_points);
@@ -1706,7 +1701,7 @@ read_tracks(void)
       const msg_track_header_t* p = (msg_track_header_t*) msg_array[i].data;
       if (le_readu32(p->total_points)) {
         track_array[i] = route_head_alloc();
-        track_array[i]->rte_name = xstrdup(p->name);
+        track_array[i]->rte_name = p->name;
       }
     } else {
       fatal(MYNAME ": unexpected message %x while reading track headers\n", id);
@@ -1873,7 +1868,7 @@ decode_route_shape(const void* data, unsigned* wp_array_i)
     wp->latitude = delbin_rad2deg(le_read32(p->point[i].latitude));
     wp->longitude = delbin_rad2deg(le_read32(p->point[i].longitude));
     sprintf(buf, "SHP%03u", j);
-    wp->shortname = xstrdup(buf);
+    wp->shortname = buf;
   }
   *wp_array_i = j;
 }
@@ -1886,7 +1881,7 @@ decode_route_point(const void* data)
   gbfile* fd = gbfopen(NULL, "w", MYNAME);
   waypoint* wp = waypt_new();
   if (p->name[0]) {
-    wp->shortname = xstrdup(p->name);
+    wp->shortname = p->name;
   }
   // give these a higher priority than the shape points
   wp->route_priority = 1;
@@ -2094,7 +2089,7 @@ read_routes(void)
     unsigned id = message_get_id(&msg_array[i]);
     if (id == MSG_ROUTE_HEADER_OUT) {
       route_array[i] = route_head_alloc();
-      route_array[i]->rte_name = xstrdup(((msg_route_header_t*)msg_array[i].data)->name);
+      route_array[i]->rte_name = ((msg_route_header_t*)msg_array[i].data)->name;
     } else {
       fatal(MYNAME ": unexpected message %x while reading route headers\n", id);
     }
@@ -2292,7 +2287,7 @@ decode_navmsg(const void* data)
   wp->course /= 100;
   wp->wpt_flags.course = 1;
   decode_sat_fix(wp, p->fix_status);
-  wp->shortname = xstrdup("Position");
+  wp->shortname = "Position";
   return wp;
 }
 
index d37a2ea74b56ceda98dfc9aa54df208ca0777056..b8ad6d5d483e4167016bb6777b7b5706507d8dd5 100644 (file)
@@ -261,8 +261,8 @@ process_gpsfile(uint8_t data[], route_head** track)
       strftime(buf, 4096, "DG-100 tracklog (%Y/%m/%d %H:%M:%S)",
                gmtime(&creation_time));
       *track = route_head_alloc();
-      (*track)->rte_name = xstrdup(buf);
-      (*track)->rte_desc = xstrdup("DG-100 GPS tracklog data");
+      (*track)->rte_name = buf;
+      (*track)->rte_desc = "DG-100 GPS tracklog data";
       track_add_head(*track);
     }
 
index 111e4cd20ddc9d464792648f21da37832595d37e..b6f9c4dbce7769f478c35c6adc9b43868cb0bd18 100644 (file)
@@ -341,7 +341,7 @@ waypt_read(void)
     waypoint* wpt = waypt_new();
     wpt->latitude = gps_save_lat;
     wpt->longitude = gps_save_lon;
-    wpt->shortname = xstrdup("Position");
+    wpt->shortname = "Position";
     if (gps_save_time) {
       wpt->SetCreationTime(gps_save_time);
     }
@@ -356,15 +356,10 @@ waypt_read(void)
   for (i = 0; i < n; i++) {
     waypoint* wpt_tmp = waypt_new();
 
-    wpt_tmp->shortname = xstrdup(way[i]->ident);
-    wpt_tmp->description = xstrdup(way[i]->cmnt);
-#if NEW_STRINGS 
+    wpt_tmp->shortname = way[i]->ident;
+    wpt_tmp->description = QString(way[i]->cmnt).simplified();
     wpt_tmp->shortname = wpt_tmp->shortname.simplified();
     wpt_tmp->description = wpt_tmp->description.simplified();
-#else
-    rtrim(wpt_tmp->shortname);
-    rtrim(wpt_tmp->description);
-#endif
     wpt_tmp->longitude = way[i]->lon;
     wpt_tmp->latitude = way[i]->lat;
     if (gps_waypt_type == 103) {
@@ -481,7 +476,7 @@ track_read(void)
     if (trk_head == NULL || array[i]->ishdr) {
       trk_head = route_head_alloc();
       trk_head->rte_num = trk_num;
-      trk_head->rte_name = xstrdup(trk_name);
+      trk_head->rte_name = trk_name;
       trk_num++;
       track_add_head(trk_head);
     }
@@ -503,7 +498,7 @@ track_read(void)
     wpt->altitude = array[i]->alt;
     wpt->heartrate = array[i]->heartrate;
     wpt->cadence = array[i]->cadence;
-    wpt->shortname = xstrdup(array[i]->trk_ident);
+    wpt->shortname = array[i]->trk_ident;
     wpt->SetCreationTime(array[i]->Time);
     wpt->wpt_flags.is_split = checkWayPointIsAtSplit(wpt, laps,
                               nlaps);
@@ -562,7 +557,7 @@ route_read(void)
       rte_head = route_head_alloc();
       route_add_head(rte_head);
       if (csrc) {
-        rte_head->rte_name = xstrdup(csrc);
+        rte_head->rte_name = csrc;
       }
     } else {
       if (array[i]->islink)  {
@@ -620,7 +615,7 @@ lap_read_as_track(void)
       /*For D906, we would like to use the track_index in the last packet instead...*/
       trk_head->rte_num = ++trk_num;
       strftime(tbuf, 32, "%Y-%m-%dT%H:%M:%SZ", stmp);
-      trk_head->rte_name = xstrdup(tbuf);
+      trk_head->rte_name = tbuf;
       track_add_head(trk_head);
 
       wpt = waypt_new();
@@ -634,11 +629,11 @@ lap_read_as_track(void)
       wpt->microseconds = 0;
 
       sprintf(tbuf, "#%d-0", index);
-      wpt->shortname = xstrdup(tbuf);
+      wpt->shortname = tbuf;
       sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d",
               array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
               array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method);
-      wpt->description = xstrdup(tbuf);
+      wpt->description = tbuf;
       track_add_wpt(trk_head, wpt);
     }
     /*Allow even if no correct location, no skip if invalid */
@@ -657,12 +652,12 @@ lap_read_as_track(void)
     wpt->microseconds = 10000*(array[i]->total_time % 100);
     /*Add fields with no mapping in the description */
     sprintf(tbuf, "#%d", index);
-    wpt->shortname = xstrdup(tbuf);
+    wpt->shortname = tbuf;
     sprintf(tbuf, "D:%f Cal:%d MS:%f AH:%d MH:%d AC:%d I:%d T:%d (%f,%f)",
             array[i]->total_distance, array[i]->calories, array[i]->max_speed, array[i]->avg_heart_rate,
             array[i]->max_heart_rate, array[i]->avg_cadence, array[i]->intensity, array[i]->trigger_method,
             array[i]->begin_lon, array[i]->begin_lat);
-    wpt->description = xstrdup(tbuf);
+    wpt->description = tbuf;
 
     track_add_wpt(trk_head, wpt);
   }
@@ -761,7 +756,7 @@ pvt_read(posn_status* posn_status)
     pvt2wpt(pvt, wpt);
     GPS_Pvt_Del(&pvt);
 
-    wpt->shortname = xstrdup("Position");
+    wpt->shortname = "Position";
 
     if (gps_errno && posn_status) {
       posn_status->request_terminate = 1;
index e51120fc80c607f0411ff325705e0b6bc2c0851a..ad985d26910bdb38f37c4ac88d38da59bb43b28b 100644 (file)
@@ -144,12 +144,6 @@ void       gl_trk_s(xg_string args, const QXmlStreamAttributes* unused)
   trk_head = route_head_alloc();
   track_add_head(trk_head);
 }
-#if 0
-void   gl_trk_ident(xg_string args, const QXmlStreamAttributes* unused)
-{
-  trk_head->rte_name = xstrdup(args);
-}
-#endif
 
 void   gl_trk_pnt_s(xg_string args, const QXmlStreamAttributes* unused)
 {
@@ -168,29 +162,17 @@ void      gl_trk_utc(xg_string args, const QXmlStreamAttributes* unused)
 
 void   gl_trk_lat(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->latitude = args.toDouble();
-#else
-  wpt_tmp->latitude = atof(args);
-#endif
 }
 
 void   gl_trk_long(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->longitude = args.toDouble();
-#else
-  wpt_tmp->longitude = atof(args);
-#endif
 }
 
 void   gl_trk_alt(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->altitude = args.toDouble();
-#else
-  wpt_tmp->altitude = atof(args);
-#endif
 }
 
 
index c595cad0c5e7cbca59aacfd38b223271d05ff511..bb8c43bb6fa5dc3c491c9b872289a89a346806ea 100644 (file)
@@ -103,13 +103,7 @@ static void
 ignr_descr(xg_string args, const QXmlStreamAttributes* attrv)
 {
   ignr_xml_error((track == NULL));
-#if NEW_STRINGS
   track->rte_desc = args;
-#else
-  if ((args != NULL) && (strlen(args) > 0)) {
-    track->rte_desc = xstrdup(args);
-  }
-#endif
 }
 
 static void
index faae951cc7de5294b0bea0e972be956eb3b2b1b9..462fd744a14f6b2b04fc7e487be1f1eec9f9dda4 100644 (file)
@@ -219,11 +219,7 @@ lmx_print(const waypoint* wpt)
   if (!oname.isEmpty()) {
     lmx_write_xml(0x48, oname, 3); // name
   }
-#if NEW_STRINGS
   if (!wpt->description.isEmpty()) {
-#else
-  if (wpt->description) {
-#endif
     lmx_write_xml(0x49, wpt->description, 3); // description
   }
   lmx_start_tag(0x4A, 3); // coordinates
@@ -354,51 +350,31 @@ lmx_lm_end(xg_string args, const QXmlStreamAttributes* unused)
 static void
 lmx_lm_lat(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->latitude = args.toDouble();
-#else
-  wpt_tmp->latitude = atof(args);
-#endif
 }
 
 static void
 lmx_lm_lon(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->longitude = args.toDouble();
-#else
-  wpt_tmp->longitude = atof(args);
-#endif
 }
 
 static void
 lmx_lm_alt(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->altitude = args.toDouble();
-#else
-  wpt_tmp->altitude = atof(args);
-#endif
 }
 
 static void
 lmx_lm_name(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->shortname = args;
-#else
-  wpt_tmp->shortname = xstrdup(args);
-#endif
 }
 
 static void
 lmx_lm_desc(xg_string args, const QXmlStreamAttributes* unused)
 {
-#if NEW_STRINGS
   wpt_tmp->description = args;
-#else
-  wpt_tmp->description = xstrdup(args);
-#endif
 }
 
 static void
index 4ceb34b09680947cf42f8ecdc17958c480b471a5..87ae9362705b27f765b0bbfaad62b1fe48efc538 100644 (file)
@@ -632,21 +632,12 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR
     mps_depth = wpt->depth;
   }
   QString src;
-#if NEW_STRINGS
   if (!wpt->description.isEmpty()) {
     src = wpt->description;
   }
   if (!wpt->notes.isEmpty()) {
     src = wpt->notes;
   }
-#else
-  if (wpt->description) {
-    src = wpt->description;
-  }
-  if (wpt->notes) {
-    src = wpt->notes;
-  }
-#endif
   QString ident = global_opts.synthesize_shortnames ?
           mkshort(mkshort_handle, src) :
           CSTRc(wpt->shortname);
@@ -663,11 +654,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR
   icon = mps_converted_icon_number(icon, mps_ver, MAPSOURCE);
 
   /* two NULL (0x0) bytes at end of each string */
-#if NEW_STRINGS
   ascii_description = xstrdup(wpt->description);
-#else
-  ascii_description = wpt->description ? xstrdup(wpt->description) : xstrdup("");
-#endif
   reclen = ident.length() + strlen(ascii_description) + 2;
   if ((mps_ver == 4) || (mps_ver == 5)) {
     /* v4.06 & V5.0*/
@@ -764,11 +751,7 @@ mps_waypoint_w(gbfile* mps_file, int mps_ver, const waypoint* wpt, const int isR
   gbfwrite(zbuf, 2, 1, mps_file);              /* unknown */
   if ((mps_ver == 4) || (mps_ver == 5)) {
     gbfwrite(zbuf, 4, 1, mps_file);    /* unknown */
-#if NEW_STRINGS
     if (!wpt->notes.isEmpty()) {
-#else
-    if (wpt->notes) {
-#endif
       gbfputs(wpt->notes, mps_file);
     }
     gbfwrite(zbuf, 1, 1, mps_file);    /* string termination */
@@ -1037,7 +1020,7 @@ mps_route_r(gbfile* mps_file, int mps_ver, route_head** rte)
         fprintf(stderr, "mps_route_r: reached the point we never should\n");
 #endif
         thisWaypoint = waypt_new();
-        thisWaypoint->shortname = xstrdup(wptname);
+        thisWaypoint->shortname = wptname;
         thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
         thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
         thisWaypoint->altitude = mps_altitude;
@@ -1121,7 +1104,7 @@ mps_route_r(gbfile* mps_file, int mps_ver, route_head** rte)
     } else {
       /* should never reach here, but we do need a fallback position */
       thisWaypoint = waypt_new();
-      thisWaypoint->shortname = xstrdup(wptname);
+      thisWaypoint->shortname = wptname;
       thisWaypoint->latitude = GPS_Math_Semi_To_Deg(lat);
       thisWaypoint->longitude = GPS_Math_Semi_To_Deg(lon);
       thisWaypoint->altitude = mps_altitude;
@@ -1201,18 +1184,10 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte)
       }
 
       QString src;
-#if NEW_STRINGS
       if (!testwpt->description.isEmpty()) {
-#else
-      if (testwpt->description) {
-#endif
         src = testwpt->description;
       }
-#if NEW_STRINGS
       if (!testwpt->notes.isEmpty()) {
-#else
-      if (testwpt->notes) {
-#endif
         src = testwpt->notes;
       }
       QString ident = global_opts.synthesize_shortnames ?
@@ -1228,11 +1203,7 @@ mps_routehdr_w(gbfile* mps_file, int mps_ver, const route_head* rte)
     }
 
     /* route name */
-#if NEW_STRINGS
     if (rte->rte_name.isEmpty()) {
-#else
-    if (!rte->rte_name) {
-#endif
       sprintf(hdr, "Route%04x", (unsigned) uniqueValue);
       rname = xstrdup(hdr);
     } else {
@@ -1431,21 +1402,12 @@ mps_routedatapoint_w(gbfile* mps_file, int mps_ver, const waypoint* rtewpt)
   }
 
   QString src;
-#if NEW_STRINGS
   if (!rtewpt->description.isEmpty()) {
     src = rtewpt->description;
   }
   if (!rtewpt->notes.isEmpty()) {
     src = rtewpt->notes;
   }
-#else
-  if (rtewpt->description) {
-    src = rtewpt->description;
-  }
-  if (rtewpt->notes) {
-    src = rtewpt->notes;
-  }
-#endif
   QString ident = global_opts.synthesize_shortnames ?
           mkshort(mkshort_handle, src) :
           CSTRc(rtewpt->shortname);
@@ -1643,11 +1605,7 @@ mps_trackhdr_w(gbfile* mps_file, int mps_ver, const route_head* trk)
     }
 
     /* track name */
-#if NEW_STRINGS
     if (trk->rte_name.isEmpty()) {
-#else
-    if (!trk->rte_name) {
-#endif
       sprintf(hdr, "Track%04x", (unsigned) uniqueValue);
       tname = xstrdup(hdr);
     } else {
index b6b9e6b9de9e89f61f9ab35ace122182dcb43e55..b886905ff5b9fb19494cd31733af714a92516dbb 100644 (file)
@@ -521,29 +521,17 @@ mmo_read_CObjWaypoint(mmo_data_t* data)
     }
 
     if (*cend++) {
-#if NEW_STRINGS
       wpt->notes = QString::fromLatin1(cend);
-#else
-      wpt->notes = xstrdup(cend);
-#endif
     }
 
     if (wpt->HasUrlLink()) {
       DBG((sobj, "url = \"%s\"\n", wpt->url));
     }
   } else if (*str) {
-#if NEW_STRINGS
     wpt->notes = QString::fromLatin1(str);
-#else
-    wpt->notes = xstrdup(str);
-#endif
   }
   xfree(str);
-#if NEW_STRINGS
   if (!wpt->notes.isEmpty()) {
-#else
-  if (wpt->notes) {
-#endif
     DBG((sobj, "notes = \"%s\"\n", wpt->notes));
   }
 
@@ -990,13 +978,13 @@ mmo_finalize_rtept_cb(const waypoint* wptref)
 
     wpt->latitude = wpt2->latitude;
     wpt->longitude = wpt2->longitude;
-    wpt->shortname = (wpt2->shortname);
+    wpt->shortname = wpt2->shortname;
 
-    wpt->description = (wpt2->description);
+    wpt->description = wpt2->description;
     wpt->notes = (wpt2->notes);
     if (wpt2->HasUrlLink()) {
       UrlLink l = wpt2->GetUrlLink();
-      wpt->notes = xstrdup(l.url_.toUtf8().data());
+      wpt->notes = l.url_;
     }
 
     wpt->proximity = wpt2->proximity;
index c47e0a318d718bbf8c7349036d1e941ae870af99..ca89cb8dbd4795e20b720040973febbcb426a523 100644 (file)
@@ -408,13 +408,8 @@ data_read(void)
 
     /* put the data in the waypoint structure */
     ng_convert_datum(wpt_tmp);
-#if NEW_STRINGS
     wpt_tmp->shortname = codec->toUnicode(WPNC.strName);
     wpt_tmp->description = codec->toUnicode(strComment);
-#else
-    wpt_tmp->shortname = xstrdup(WPNC.strName);
-    wpt_tmp->description = xstrdup(strComment);
-#endif
 
     if (process_rte) {
       route_add_wpt(rte_head, wpt_tmp);
index 0d4d54a8603c1eea63936f491330844e6588a120..48b961d0058142e04fe364ac853a08bd1df5a5e5 100644 (file)
@@ -207,11 +207,7 @@ compare_waypoints(const waypoint* waypt1, const waypoint* waypt2)
   return waypt1->latitude == waypt2->latitude &&
          waypt1->longitude == waypt2->longitude &&
          waypt1->altitude == waypt2->altitude &&
-#if NEW_STRINGS
          waypt1->shortname == waypt2->shortname;
-#else
-         strcmp(waypt1->shortname, waypt2->shortname) == 0;
-#endif
 }
 
 unsigned
index d285a0c5e96d76062e737b2c501587ea511fe32e..ae19f5b7eb2c29e85a58a4b9732633d1d94ba283 100644 (file)
@@ -222,11 +222,7 @@ static void route_add_name(const route_head* hd)
   route_head* route;
 
   route = (route_head*) hd;
-#if NEW_STRINGS
   grp = route->rte_name.toInt();
-#else
-  grp = atoi(route->rte_name);
-#endif
   i = 0;
   while (i<groups_cnt && groups[i].group!=grp) {
     i++;
@@ -237,12 +233,7 @@ static void route_add_name(const route_head* hd)
   } else {
     strcpy(name,groups[i].name);
   }
-#if NEW_STRINGS
   route->rte_name = name;
-#else
-  route->rte_name = (char*) xrealloc(route->rte_name,(strlen(name)+1)*sizeof(char));
-  strcpy(route->rte_name,name);
-#endif
 }
 
 static void ovl_read(void)
@@ -299,7 +290,7 @@ static void ovl_read(void)
             case 3: // Linie
               route_head = route_head_alloc();
               route_head->rte_num = sym_cnt;
-              route_head->rte_name = xstrdup(pstr); /* use group-number for the moment */
+              route_head->rte_name = pstr; /* use group-number for the moment */
               route_add_head(route_head);
               break;
             }
@@ -375,7 +366,7 @@ static void ovl_read(void)
               wpt->latitude = aktY;
               wpt->longitude = aktX;
               wpt->altitude = 0.0;
-              wpt->shortname = strdup(aktPath);
+              wpt->shortname = aktPath;
               waypt_add(wpt);
               break;
 #endif
index c9a32c20c7414ab1c9fb1e314003ed8d78d2dd44..7ee7136be094c08eb8cf70acfe655b7a7fe9ee73 100644 (file)
@@ -246,11 +246,7 @@ ozi_track_hdr(const route_head* rte)
     ozi_openfile(ozi_ofname);
     gbfprintf(file_out, ozi_trk_header,
               altunit == 'f' ? "Feet" : "Meters",
-#if NEW_STRINGS
               rte->rte_name.isEmpty() ? "ComplimentsOfGPSBabel" : CSTRc(rte->rte_name));
-#else
-              rte->rte_name ? CSTRc(rte->rte_name) : "ComplimentsOfGPSBabel");
-#endif
   }
 
   track_out_count++;
@@ -320,13 +316,8 @@ ozi_route_hdr(const route_head* rte)
 
   gbfprintf(file_out, "R,%d,%s,%s,\r\n",
             route_out_count,
-#if NEW_STRINGS
             CSTRc(rte->rte_name),
             CSTRc(rte->rte_desc));
-#else
-            rte->rte_name ? CSTRc(rte->rte_name) : "",
-            rte->rte_desc ? CSTRc(rte->rte_desc) : "");
-#endif
 }
 
 static void
@@ -370,19 +361,11 @@ ozi_route_disp(const waypoint* waypointp)
   gbfprintf(file_out, "W,%d,,%d,%s,%.6f,%.6f,%s,0,1,3,0,65535,%s,0,0\r\n",
             route_out_count,
             route_wpt_count,
-#if NEW_STRINGS
             CSTR(waypointp->shortname),
-#else
-            waypointp->shortname ? CSTRc(waypointp->shortname) : "",
-#endif
             waypointp->latitude,
             waypointp->longitude,
             ozi_time,
-#if NEW_STRINGS
             CSTR(waypointp->description));
-#else
-            waypointp->description ? CSTRc(waypointp->description) : "");
-#endif
 
 }
 
@@ -787,7 +770,7 @@ data_read(void)
       while (s) {
         field ++;
         if (field == 4) {
-          trk_head->rte_name = xstrdup(lrtrim(s));
+          trk_head->rte_name = QString(s).trimmed();
         }
         s = csv_lineparse(NULL, ",", "", linecount);
       }
@@ -886,13 +869,8 @@ ozi_waypt_pr(const waypoint* wpt)
   static int index = 0;
   double alt;
   char ozi_time[16];
-#if NEW_STRINGS
   QString description;
   QString shortname;
-#else
-  char* description;
-  char* shortname;
-#endif
   int faked_fsdata = 0;
   ozi_fsdata* fs = NULL;
   int icon = 0;
@@ -911,13 +889,8 @@ ozi_waypt_pr(const waypoint* wpt)
   } else {
     alt = wpt->altitude * alt_scale;
   }
-#if NEW_STRINGS
   if ((wpt->shortname.isEmpty()) || (global_opts.synthesize_shortnames)) {
     if (!wpt->description.isEmpty()) {
-#else
-  if ((!wpt->shortname) || (global_opts.synthesize_shortnames)) {
-    if (wpt->description) {
-#endif
       if (global_opts.synthesize_shortnames) {
         shortname = mkshort_from_wpt(mkshort_handle, wpt);
       } else {
@@ -930,13 +903,8 @@ ozi_waypt_pr(const waypoint* wpt)
   } else {
     shortname = csv_stringclean(wpt->shortname, BADCHARS);
   }
-#if NEW_STRINGS
   if (wpt->description.isEmpty()) {
     if (!shortname.isEmpty()) {
-#else
-  if (!wpt->description) {
-    if (shortname) {
-#endif
       description = csv_stringclean(shortname, BADCHARS);
     } else {
       description = xstrdup("");
@@ -963,11 +931,6 @@ ozi_waypt_pr(const waypoint* wpt)
     gbfprintf(file_out,"%d,", 0);
   }
   gbfprintf(file_out, "%.0f,%d,%d,%d\r\n", alt, 6, 0, 17);
-#if NEW_STRINGS
-#else
-  xfree(description);
-  xfree(shortname);
-#endif
 
   if (faked_fsdata) {
     xfree(fs);
index 10cc2b8c944715918b83125c8f7daf6e0bd53eb3..9bfa1b8b40f071497979963a2d87344529cdc29f 100644 (file)
@@ -167,7 +167,7 @@ radius_process(void)
 
   if (routename) {
     rte_head = route_head_alloc();
-    rte_head->rte_name = xstrdup(routename);
+    rte_head->rte_name = routename;
     route_add_head(rte_head);
   }
 
index 8f7f6c6f44026f85da0ea36f240e9e10b5e5adc0..91d20ddca4a46a87589613b6aabd74ac252ac946 100644 (file)
@@ -169,7 +169,7 @@ my_read(void)
     case SHPT_ARC: {
       int j;
       route_head* routehead = route_head_alloc();
-      routehead->rte_name = xstrdup(name);
+      routehead->rte_name = name;
       route_add_head(routehead);
       for (j = 0; j < shp->nVertices; j++) {
         wpt = waypt_new();
index 0cbd2531aa5d3d42173f514c16d99ce5a3347a5c..96ebe278238dc7802920ff0f25ccb56bc25a9151 100644 (file)
@@ -135,11 +135,7 @@ stmwpp_data_read(void)
         break;
 
       case 2:
-#if NEW_STRINGS
         wpt->shortname = QString::fromLatin1(c);
-#else
-        wpt->shortname = xstrdup(c);
-#endif
         break;
 
       case 3:
index 190f2eb1fe6efa5071bf303380f20086e85af205..e8338141be44b8c432aeb88b71f97e9c535ff6ee 100644 (file)
@@ -121,13 +121,9 @@ transform_rte_disp_hdr_cb(const route_head* rte)
   if (current_target == 'T') {
     current_trk = route_head_alloc();
     track_add_head(current_trk);
-#if NEW_STRINGS
      if (!rte->rte_name.isEmpty()) {
-#else
-    if (rte->rte_name && *rte->rte_name) {
-#endif
       xasprintf(&current_trk->rte_desc, "Generated from route %s", CSTRc(rte->rte_name));
-      current_trk->rte_name = xstrdup(rte->rte_name); /* name the new trk */
+      current_trk->rte_name = rte->rte_name; /* name the new trk */
     }
   }
 }
@@ -146,18 +142,11 @@ transform_trk_disp_hdr_cb(const route_head* trk)
   if (current_target == 'R') {
     current_rte = route_head_alloc();
     route_add_head(current_rte);
-#if NEW_STRINGS
     if (!trk->rte_name.isEmpty()) {
       current_rte->rte_desc = "Generated from track ";
       current_rte->rte_desc += trk->rte_name;
       current_rte->rte_name = trk->rte_name; /* name the new rte */
     }
-#else
-    if (trk->rte_name && *trk->rte_name) {
-      xasprintf(&current_rte->rte_desc, "Generated from track %s", CSTRc(trk->rte_name));
-      current_rte->rte_name = xstrdup(trk->rte_name); /* name the new rte */
-    }
-#endif
   }
 }